export function downloadByBlob(blob, filename) {
	filename = filename || `zb_file`
	const file = new File([blob], filename)
	downloadByFile(file)
}

export function downloadByFile(file) {
	const link = document.createElement('a')
	link.download = file.name
	link.href = URL.createObjectURL(file)
	document.body.appendChild(link)
	link.click()
}

export function downloadByResponse(response) {
	const filename = response.headers['content-disposition']
		.split(';')[1]
		.split('=')[1]
	downloadByBlob(response.data, decodeURIComponent(filename))
}
